import express from "express";
import classCont from "./controller";
const classRouter = express.Router();
import auth from "../../common/middleware/auth";
import commonUserMidd from "../../common/middleware/user";
import classMidd from "./middleware";

/**
 * 新建班级
 */
classRouter.post(
  "/create",
  auth.vertify,
  commonUserMidd.isTch,
  classMidd.isClassExist,
  classCont.createClass
);

/**
 * 删除班级
 */
classRouter.delete(
  "/delete",
  auth.vertify,
  commonUserMidd.isTch,
  classMidd.isUserHasClass,
  classCont.delClass
);

/**
 * 学生添加到班级
 */
classRouter.post(
  "/add",
  auth.vertify,
  commonUserMidd.isStu,
  classMidd.isClassExistFromCommandWord,
  classMidd.getClassIdFromCommandWord,
  classMidd.isRepeatAddClass,
  classCont.addClass
);

/**
 * 把学生移除出班级
 */
classRouter.delete(
  "/removeStu",
  auth.vertify,
  commonUserMidd.isTch,
  classMidd.isAddClass,
  classCont.removeClass
);

/**
 * 获取所有的班级信息
 */
classRouter.get(
  "/getAll",
  auth.vertify,
  commonUserMidd.isTch,
  classCont.getClass
);

/**
 * 获取一个班级的信息
 */
classRouter.get("/getOne/:id", auth.vertify, classCont.getOne);

/**
 * 编辑班级信息
 */
classRouter.put("/edit", auth.vertify, classCont.editClas);

/**
 * 获取学生的班级
 */
classRouter.get("/getStuClass", auth.vertify, classCont.getStuClass);

/**
 * 学生退出班级
 */
classRouter.delete('/exitStuClass/:id', auth.vertify, classCont.exitStuClass)

/**
 * 教师信息
 */
classRouter.get('/getTchInfo', auth.vertify, classCont.getTchInfo)

export default classRouter;
